package MapJoin;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class MJDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException, URISyntaxException {
        //定义输入输出路径
        args=new String[]{"E:\\test\\Order_data\\order.txt","E:\\test\\temp\\MJOrder_data"};

        //创建配置文件
        Configuration conf = new Configuration();
        //创建Job任务
        Job job = Job.getInstance(conf);

        //设置Driver反射
        job.setJarByClass(MJDriver.class);

        //设置Mapper反射
        job.setMapperClass(MJMapper.class);
        //设置Mapper的输出（key,value）类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);



        //指定输入输出路径
        FileInputFormat.setInputPaths(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));
        //加载缓存：
        job.addCacheFile(new URI("file:///E:/test/Order_data/pd.txt"));

        //提交job任务到yarn执行
        boolean isSuccess = job.waitForCompletion(true);
        System.exit(isSuccess?0:-1);
    }
}
